Compile MAME using GCC 11.2.0 on Windows XP
===========================================

This is a guide to compile the newest MAME version on Windows XP. Since MAME 0.227 you need at least 4GB of working memory to compile MAME
on Windows XP. Also the Windows XP's "Virtual Address Space" is limited to 2 GB RAM. To remove this limitation download the file:
http://www.mediafire.com/download/i7nhh6hj8af63ui/Gamersky-WindowsXP_64G_RAM.7z

and extract the files hal64g.dll and ntkl64g.exe to C:\windows\system32\
Use an editor to add the parameters /kernel=ntkl64g.exe /hal=hal64g.dll /3gb /USERVA=3008 /PAE to the c:\boot.ini file:

Example from:
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /noexecute=OptIn /fastdetect /nodebug
to
multi(0)disk(0)rdisk(0)partition(1)\WINDOWS="Microsoft Windows XP Professional" /kernel=ntkl64g.exe /hal=hal64g.dll /3gb /USERVA=3008 /PAE /noexecute=OptIn /fastdetect /nodebug

Reboot your PC.

For more informations see:
https://www.xpforums.com/threads/guide-to-enable-windows-xp-to-use-more-than-3-25gb-ram.932418/
https://msfn.org/board/topic/176356-simple-xp-32bit-64gb-ram-true-pae-guide/
https://docs.microsoft.com/en-us/windows/win32/memory/4-gigabyte-tuning?redirectedfrom=MSDN



Build the compile system
------------------------

* Download the buildtool: https://github.com/mamedev/buildtools/releases/download/1.5/msys32-2016-02-16.exe
  Double-click on  msys32-2016-02-16.exe  and extract the files in a directory of your choice.
  Open the new directory  msys32  and rename  'buildtools.bat'  to  'Windows Console.bat'. Start  autorebase.bat  to correct the MingW location.
* Download the 'Update-Packages.zip'. This file is split due to GitHub's file size limit. 

  https://github.com/MASHinfo/mameinfo/raw/refs/heads/main/download/Update-Packages_2.7z.001
  https://github.com/MASHinfo/mameinfo/raw/refs/heads/main/download/Update-Packages_2.7z.002
  https://github.com/MASHinfo/mameinfo/raw/refs/heads/main/download/Update-Packages_2.7z.003
  https://github.com/MASHinfo/mameinfo/raw/refs/heads/main/download/Update-Packages_2.7z.004

  Open the file 'Update-Packages_2.zip.001' with 7zip and extract the file 'Update-Packages.zip' into  msys32\src.
  Open  'Compile MAME.zip'  and extract all files in the 'Scripts' folder also into msys32\src.
* Make sure you are connected to the internet.
  Start the 'Windows Console.bat' and type/paste into the console  init.sh  and press enter.
  The script will now update the old buildtool from GCC 5.3 to GCC 11.2.0 (20-Oct-2021) and downloaded the newest MAME source.
* You can go offline!
* Restart Windows Console.bat and type/paste   make -j5   into the console to compile MAME.


Speed up compiling process with (-j) option
-------------------------------------------
make -j3          (3x files; Dual Core CPU and 4GB RAM)
make -j5          (5x files; Quad Core and 8GB RAM)
make -j7          (7x files; Six Core and > 16GB RAM)
.
.
.

Compile different MAME versions
-------------------------------
MAME                  make -j5
ARCADE                make -j5 SUBTARGET=arcade
MESS                  make -j5 SUBTARGET=mess
TINYMAME              make -j5 SUBTARGET=tinymame SOURCES=src/mame/???/ANY--DRIVER--YOU--WANT.cpp REGENIE=1
  TINYMAME-Example    make -j5 SUBTARGET=tinymame SOURCES=src/mame/namco/rallyx.cpp REGENIE=1
ARCADE MAMEUI         make -j5 OSD=winui SUBTARGET=arcade     NOTE: This version needs the extra winui files from https://github.com/Robbbert/mameui



Process Explorer
----------------
Follow the compile process with Process Explorer to see if you have enough memory. Press on 'Private bytes' tab
for the biggest files compiled with cc1plus.exe.
Download 'Process Explorer v16.21' for Windows XP here: http://filepony.de/download-process_explorer/



The final 32bit MAME file
-------------------------
The final  mame.exe  or  tinymame.exe  can you find in the folder  msys32\src\mame-master
To use it you need some extra files that are in the latest MAME version from https://www.mamedev.org/release.html.
Download this file and extract all files in a directory of your choice and replace the
mame.exe with your new compiled MAME version.

Now open a command prompt and jump into your MAME directory and type/paste:  mame.exe -cc
to generate the ini-files:  mame.ini,  plugin.ini  and  ui.ini.
Move these files into the MAME/ini directory and make the following changes
to the mame.ini with an editor:

inipath                   ini;ini/presets
snapbilinear              0
keyboardprovider          dinput
mouseprovider             dinput
video                     d3d
maximize                  0
filter                    0
sound                     dsound

Copy a game for example rallyx.zip into the rom directory and start MAME to test it!





Compile a new/updated MAME version
----------------------------------
Start the 'Windows Console.bat' and connect to the internet.
Type/Paste the following commands into the console:

cd /src
git.sh
cd mame-master
make -j5



Compile the official MAME source
--------------------------------
Download the official MAME source from https://www.mamedev.org/release.php
Delete the old source folder  mame-master  in the msys32\src directory.
Create a new  mame-master  folder and extract the official source into it!
Start the 'Windows Console.bat' and connect to the internet.
Type/Paste the following commands into the console:

patch.sh
cd mame-master
make -j5



Windows 10 (64bit)
------------------
To compile a working Windows XP version under Windows 10 you must add 'PTR64=0' to the make command,
like  'make -j5 TARGET=mame SUBTARGET=arcade PTR64=0'  or changed the line 50
in the file  src\mame-master\makefile  from:

# PTR64 = 1
to
PTR64 = 0

This mame.exe version works of course also on XP Windows!



Keyboard shortcuts
------------------

CTRL+C    : Break compiling process
Up/Down   : Hold up last/next line
Shift+PgUp: Page up
Shift+PgDn: Page down
Shift+Home: Top
Shift+End : Bottom 
Alt+Enter : Toggle between Window Menu and Full Screen
Alt+F2    : New window
Alt+F3    : Search (in scrollback buffer)
ALT+F4    : Exit/Close window. Or you click on the window's close button or choose 'Close' from the window menu.
Alt+F8    : Reset

More shortcuts: https://mintty.github.io/mintty.1.html



Compile Tools
-------------
In the Tools directory you can find useful batch files for compiling. Before you can use
these batch files you must edit the files to correct the working directory.

'0-Byte-Deleting.bat': Deletes 0 byte files in MAME's build directory
'CP.bat'             : Compile MAME without the console. Don't forget to start msys64\autorebase.bat and
                       edit the CP.bat to correct the MingW location.
'DOB.bat'            : Deletes specific object files in the build directory

----------------------------------------------------------------------------------------------------

History:

-  3rd April     2026: Updated compiler to GCC 11.2.0. Fixed init.sh, git.sh and patch.sh scripts. Re-added full 'Update-Packages.zip'.
-  25th January  2026: Updated init.sh, git.sh and patch.sh scripts. Fixed arcade+mess-flt.bat and exceptions(arcade).txt.
-   5th January  2026: Split 'Update-Packages.zip' into smaller 24 MB files due to GitHub's file size limit.
-  26th December 2025: Fixed exceptions(arcade).txt and exceptions(mess).txt.
-  26th November 2025: Fixed exceptions(arcade).txt and exceptions(mess).txt.
-  28th July     2025: Fixed exceptions(mess).txt.
-    5th July    2025: Updated README.TXT.
-    4th July    2025: Re-added DirectSound.
-   25th May     2025: Fixed 'AUDCLNT_STREAMFLAGS_XXX' was not declared error by updating "mingw-w64-i686-headers-git-8.0.0" package to "mingw-w64-i686-headers-git-10.0.0".
-    1st May     2025: Fixed "MINGW32 is not set" (Added 'MINGW_PREFIX=/mingw32' to home/$USER/.bashrc) and "Error: Invalid command line parameters" (PROCESSOR_ARCHITECTURE in makefile).
                       Added "mingw-w64-i686-pkg-config-0.29.2-9003-any.pkg" package for MAME 0.278. Updated exceptions(arcade).txt and exceptions(mess).txt.
- 15th February  2025: Updated exceptions(arcade).txt. Added missing 'GetLogicalProcessorInformation' patch to git.sh and patch.sh.
- 25th January   2025: Fixed 'GetLogicalProcessorInformation' missing in kernel32.dll (init.sh).
- 18th November  2024: Updated arcade+mess-flt.bat.
-  3rd September 2024: Updated arcade+mess-flt.bat.
- 25th August    2024: Updated exceptions(arcade).txt and exceptions(mess).txt.
- 16th May       2024: Updated exceptions(mess).txt.
- 10th May       2024: Use XP compatible libzstd.dll from https://github.com/facebook/zstd . Updated exceptions(arcade).txt and init.sh script.
- 28th April     2024: Updated compiler to GCC 10.3.0. Fixed init.sh, git.sh and patch.sh scripts.
- 13th April     2024: Updated init.sh and git.sh scripts. Added patch.sh. Fixed unzip error in init.sh script.
- 25th March     2024: Updated exceptions(arcade).txt and exceptions(mess).txt.
-  9th March     2024: Updated init.sh, git.sh scripts and arcade+mess-flt.bat.
- 19th October   2023: Updated arcade+mess-flt.bat, exceptions(arcade).txt and exceptions(mess).txt.
- 25th June      2023: Updated exceptions(arcade).txt and exceptions(mess).txt.
- 13th June      2023: Updated exceptions(arcade).txt and exceptions(mess).txt.
- 31st May       2023: Updated exceptions(arcade).txt.
- 13th May       2023: Updated arcade+mess-flt.bat. 
-  5th April     2023: Correct arcade- and mess.flt files.
-  2nd April     2023: Added batch files to generate arcade/mess.flt. Updated init.sh and git.sh scripts. Added Compile Tools.
- 13th January   2023: Correct SSE version (SSE=2) in scripts/src/3rdparty.lua.
- 19th October   2022: Simplified download and init.sh script.

---------------------------------------------------------------------------------------------------------------------

Do you still have questions, then email to: mameinfo@ewetel.net


(c) 2026 MASH

